package com.shaco.heroproject.activity;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.TextView;

import com.shaco.heroproject.R;

import java.security.Key;

/**
 * Created by dllo on 15/11/5.
 */
public class WebWindowActivity extends Activity implements View.OnClickListener {
    private Button activity_back_story_backBtn;
    private TextView webTitleTv;
    private WebView webViewTv;
    private String webKey,id,title,sid,name_e,url;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_web_window);



        title = getIntent().getStringExtra("title");//标题
        webKey = getIntent().getStringExtra("webKey");
        id = getIntent().getStringExtra("id");//新闻id
        sid = getIntent().getStringExtra("sid");//攻略sid
        name_e = getIntent().getStringExtra("name_e");//攻略sid
        url = getIntent().getStringExtra("url");//查询战绩的url
//        strateg_title = getIntent().getStringExtra("strateg_title");



        Log.i("shaco", "+++++++++++++" + webKey + "-----------");

        activity_back_story_backBtn= (Button) findViewById(R.id.activity_back_story_backBtn);
        activity_back_story_backBtn.setOnClickListener(this);
        webTitleTv= (TextView) findViewById(R.id.webTitleTv);




        webViewTv= (WebView) findViewById(R.id.webViewTv);
        webTitleTv.setText(title);
        webViewTv.getSettings().setJavaScriptEnabled(true);
        webViewTv.setWebViewClient(new WebViewClient());

        switch (webKey){
            case "0"://新闻
                webViewTv.loadUrl("http://lol.data.shiwan.com/getArticleInfo/loldata?article_id=" + id);
                break;
            case "1"://攻略
                webViewTv.loadUrl("http://lol.data.shiwan.com/getSubjectInfo/?sid=" + sid);//攻略
                break;
            case "2":
                webViewTv.loadUrl("http://lolbox.duowan.com/phone/heroTop10Players.php?hero="+name_e);
                break;
            case "3":
                webViewTv.loadUrl(url);

                break;
        }

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.activity_back_story_backBtn:
                finish();
                break;
        }
    }
}